<script setup lang="ts">
import ChartLhz from '../../components/ChartLhz.vue'
import {computed} from "vue";
// import * as echarts from 'echarts';
// import 'echarts/extension/bmap/bmap';
const props = defineProps(["chart_option"])
const { chart_option } = props
console.log(chart_option[1])
const options = computed(() => {
  let option = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow'
      }
    },
    legend: {textStyle: {
        color: 'white' // 默认颜色
      },},
    toolbox: {
      feature: {
        saveAsImage: {}
      }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: [
      {
        type: 'category',
        data: ['30~50', '50~70', '70~90', '90~110']
      }
    ],
    yAxis: [
      {
        type: 'value'
      }
    ],
    series: [
      {
        name: '30~50',
        type: 'bar',
        emphasis: {
          focus: 'series'
        },
        // data: [320, 332, 301, 334, 390, 330, 320]
        data:[38,
          3,
          11,
          32,
          2]
      },
      {
        name: '',
        type: 'bar',
        stack: 'Ad',
        emphasis: {
          focus: 'series'
        },
        // data: [120, 132, 101, 134, 90, 230, 210]
        data:[25,
          5,
          55,
          69,
          7]
      },
      {
        name: '',
        type: 'bar',
        stack: 'Ad',
        emphasis: {
          focus: 'series'
        },
        // data: [220, 182, 191, 234, 290, 330, 310]
        data:[18,
          2,
          36,
          80,
          5]
      },
      {
        name: 'CO',
        type: 'bar',
        stack: 'Ad',
        emphasis: {
          focus: 'series'
        },
        data: [150, 232, 201, 154, 190, 330, 410]
      },
      {
        name: 'O3',
        type: 'bar',
        // data: [862, 1018, 964, 1026, 1679, 1600, 1570],
        data:[ 13,
          8,
          27,
          41,
          3],
        emphasis: {
          focus: 'series'
        },
        markLine: {
          lineStyle: {
            type: 'dashed'
          },
          data: [[{type: 'min'}, {type: 'max'}]]
        }
      }
    ]
  }

  option.series[0].name = chart_option[5][0]; // PM2.5 标题
  option.series[1].name = chart_option[5][1]; // PM10 标题
  option.series[2].name = chart_option[5][2]; // SO2 标题
  option.series[3].name = chart_option[5][3]; // NO2 标题
  option.series[4].name = chart_option[5][4]; // CO 标题

    // 在这里设置 series 的 data
    // option.series[0].data = chart_option[1]; // PM2.5 数据
    // option.series[1].data = chart_option[2]; // PM10 数据
    // option.series[2].data = chart_option[3]; // SO2 数据
    // option.series[3].data = chart_option[4]; // NO2 数据
    // option.series[4].data = chart_option[0]; // CO 数据
  return option

})
</script>

<template>
  <chart-lhz :chart_option="options" v-if="chart_option">1</chart-lhz>
</template>

<style scoped lang="scss">

</style>